/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.SpringVersion;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * <p>Project: springmvc2021 - IndexController
 * <p>Powered by webrx On 2021-11-04 10:59:35
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
@Controller
public class IndexController {


    @GetMapping("/") @ResponseBody
    public String hello(){
        return "hello index 中文效果 SpringMVC ver:" + SpringVersion.getVersion();
    }

    @GetMapping({"/show","/show.do","/show.action"})
    //@PostMapping
    //@PutMapping
    //@DeleteMapping
    //@RequestMapping
    public void show(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out = resp.getWriter();
        out.println("<!DOCTYPE html>");
        out.println("<html>");
        out.println("<head>");
        out.println("<meta charset=\"utf-8\">");
        out.println("<title>玉灵 QQ:7031633 Email:webrx@126.com</title>");
        out.println("<meta name=\"keywords\" content=\"关键字\">");
        out.println("<meta name=\"description\" content=\"简介\">");
        out.println("</head>");
        out.println("<body>");

        for(int i=1;i<=5;i++) {
            out.println("<h3>Hello World  中文效果"+i+"</h3>");
        }

        out.println("</body>");
        out.println("</html>");
        out.flush();
        out.close();
    }

}
